package com.ruoyi.project.para.bglInfo.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.para.bglInfo.domain.PaeaBglInfo;
import com.ruoyi.project.para.bglInfo.service.IPaeaBglInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * BGL交易抽查监控参数Controller
 *
 * @author ruoyi
 * @date 2020-03-14
 */
@Controller
@RequestMapping("/para/bglInfo")
public class PaeaBglInfoController extends BaseController
{
    private String prefix = "para/bglInfo";

    @Autowired
    private IPaeaBglInfoService paeaBglInfoService;

    @RequiresPermissions("para:bglInfo:view")
    @GetMapping()
    public String info()
    {
        return prefix + "/info";
    }

    /**
     * 查询BGL交易抽查监控参数列表
     */
    @RequiresPermissions("para:bglInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaBglInfo paeaBglInfo)
    {
        startPage();
        List<PaeaBglInfo> list = paeaBglInfoService.list(new QueryWrapper<PaeaBglInfo>(paeaBglInfo));
        return getDataTable(list);
    }

    /**
     * 导出BGL交易抽查监控参数列表
     */
    @RequiresPermissions("para:bglInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaBglInfo paeaBglInfo)
    {
        List<PaeaBglInfo> list = paeaBglInfoService.list(new QueryWrapper<PaeaBglInfo>(paeaBglInfo));
        ExcelUtil<PaeaBglInfo> util = new ExcelUtil<PaeaBglInfo>(PaeaBglInfo.class);
        return util.exportExcel(list, "bglInfo");
    }

    /**
     * 新增BGL交易抽查监控参数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存BGL交易抽查监控参数
     */
    @RequiresPermissions("para:bglInfo:add")
    @Log(title = "BGL交易抽查监控参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaBglInfo paeaBglInfo)
    {
        return toAjax(paeaBglInfoService.saveOrUpdate(paeaBglInfo));
    }

    /**
     * 修改BGL交易抽查监控参数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaBglInfo paeaBglInfo = paeaBglInfoService.getById(id);
        mmap.put("paeaBglInfo", paeaBglInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存BGL交易抽查监控参数
     */
    @RequiresPermissions("para:bglInfo:edit")
    @Log(title = "BGL交易抽查监控参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaBglInfo paeaBglInfo)
    {
        return toAjax(paeaBglInfoService.saveOrUpdate(paeaBglInfo));
    }

    /**
     * 删除BGL交易抽查监控参数
     */
    @RequiresPermissions("para:bglInfo:remove")
    @Log(title = "BGL交易抽查监控参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaBglInfoService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
